package com.DAO.Impl;

import com.DAO.coachesDAO;
import com.DBUtil.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 20x
 * @date 2024 - 12 -14
 **/
public class coachesDAOImpl implements coachesDAO {

    @Override
    public List<String> coachesNames() {
        List<String> Lists = new ArrayList<>();
        String sql = "select coachesName from coaches";
        PreparedStatement pst = null;
        ResultSet rs = null;
        Connection conn = DBUtil.getConnection();
        try {
            pst = conn.prepareStatement(sql);
            rs = pst.executeQuery();
            while (rs.next()) {
                Lists.add(rs.getString("coachesName"));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        return Lists;
    }

    public static void main(String[] args) {
        System.out.println(new coachesDAOImpl().coachesNames());
    }
}
